package com.wanmait.happyheating.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wanmait.happyheating.pojo.MaterialsName;
import com.wanmait.happyheating.mapper.MaterialsNameMapper;
import com.wanmait.happyheating.pojo.MaterialsType;
import com.wanmait.happyheating.service.MaterialsNameService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 耗材名称表 服务实现类
 * </p>
 *
 * @author yuQianTao
 * @since 2021-05-13
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class MaterialsNameServiceImpl extends ServiceImpl<MaterialsNameMapper, MaterialsName> implements MaterialsNameService {

    @Resource
    private MaterialsNameMapper materialsNameMapper;

    @Override
    public PageInfo<MaterialsName> findAllMaterialsNames(Integer pageNum,Integer pageSize) {
        //pagesize
        PageHelper.startPage(pageNum,pageSize);
        List<MaterialsName> materialsNames = materialsNameMapper.findAllMaterialsNames();
        //navigatePages
        PageInfo<MaterialsName> materialsNamePageInfo = new PageInfo<>(materialsNames,5);

        return materialsNamePageInfo;
    }

    @Override
    public PageInfo<MaterialsName> likeMaterialsNameByPage(Integer pageNum,Integer pageSize, String title) {

//        LambdaQueryWrapper<MaterialsName> materialsNameLambdaQueryWrapper = new LambdaQueryWrapper<>();
//        materialsNameLambdaQueryWrapper.like(MaterialsName::getTitle,title);
        PageHelper.startPage(pageNum,pageSize);
        List<MaterialsName> materialsNames = materialsNameMapper.likefindAllMaterialsNames(title);
        PageInfo<MaterialsName> materialsNamePageInfo = new PageInfo<>(materialsNames,5);

        return materialsNamePageInfo;
    }
}
